//
//  NSString+SYBase64.m
//  GBMD5
//
//  Created by dllo on 16/8/16.
//  Copyright © 2016年 郭宝. All rights reserved.
//

#import "NSString+SYBase64.h"

@implementation NSString (SYBase64)
- (NSString *)stringWithBase64
{
//    字符串转NSData
    NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];
    NSString *base64String = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
//    NSData转base64String
    return base64String;
}

- (NSData *)base64StringWithData
{
    return [[NSData alloc] initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
}


//- (NSString *)stringWithBase64;
//解码
- (NSString *)Base64StringWith
{
//    根据base64String生成NSData
    NSData *base64Data = [self base64StringWithData];
//    把NSData转成字符串
    NSString *orginString = [[NSString alloc] initWithData:base64Data encoding:NSUTF8StringEncoding];
    return orginString;
}
@end
